package com.example.demo.bio;

import java.net.Socket;
import java.util.Date;
import java.util.concurrent.TimeUnit;

/**
 * Description: BIO通信<br/>
 *
 * @author liulonglong
 * @taskId <br/>
 * @Date 2019/11/22 14:45
 * @Version 1.0
 */
public class IOClient {
    public static void main(String[] args) {
        new Thread(() -> {
            try {
                Socket socket = new Socket("127.0.0.1", 3333);
                while (true) {
                    try {
                        socket.getOutputStream().write((new Date() + ":hello world!").getBytes());
                        TimeUnit.SECONDS.sleep(2);
                    } catch (Exception e) {

                    }
                }
            } catch (Exception e) {

            }
        }).start();
    }

}
